import {
  axios
} from '@/utils/request'
// ecu列表
function getEcuList (params) {
  return axios({
    url: '/vehicle-service/ecu/list',
    method: 'get',
    params
  })
}
// 获取某个ECU的详情
function getEcuInfor (params) {
  return axios({
    url: '/vehicle-service/ecu/info',
    method: 'get',
    params
  })
}
// 获取满足条件的所有ecu
function getAllEcu (params) {
  return axios({
    url: '/vehicle-service/ecu/select',
    method: 'get',
    params
  })
}
// 去重后的
function getAllEcuName (params) {
  return axios({
    url: '/vehicle-service/ecu/select/name',
    method: 'get',
    params
  })
}
// 新建ecu
function addEcu (item) {
  return axios({
    url: '/vehicle-service/ecu',
    method: 'post',
    data: item
  })
}
// 编辑等保存
function editEcu (item) {
  return axios({
    url: '/vehicle-service/ecu',
    method: 'put',
    data: item
  })
}

// 批量删除
function batchDeleteCarEcu (ids) {
  return axios({
    url: '/vehicle-service/ecu',
    method: 'delete',
    data: ids
  })
}
// 制造商下拉框
function getSupplier (params) {
  return axios({
    url: '/vehicle-service/ecu/select/supplier',
    method: 'get',
    params
  })
}
// ecu软件DID下拉框
function getSoftDID (data) {
  return axios({
    url: '/vehicle-service/ecu/select/softwareDid',
    method: 'get',
    params: data
  })
}

function importEcuList (params) {
  return axios({
    url: '/vehicle-service/import/ecu',
    method: 'post',
    data: params,
    timeout: 120000
  })
}

function importEcuTemplate () {
  return axios({
    url: '/vehicle-service/import/template/ecu',
    method: 'get',
    responseType: 'blob'
  })
}

// ECU列表导出
function exportEcuList (params) {
  return axios({
    url: '/vehicle-service/ecu/export',
    method: 'get',
    params: params,
    responseType: 'blob'
  })
}
// ECU 同步
function syncEcuGcy () {
  return axios({
    url: '/vehicle-service/ecu/sync/gcy',
    method: 'post'
  })
}


// 根据车型代码获取ecu列表
function getEcuListByModelCode (params) {
  return axios({
    url: '/vehicle-service/ecu/select/model-code',
    method: 'get',
    params: params
  })
}
export default {
  getEcuList,
  getEcuInfor,
  getAllEcu,
  getAllEcuName,
  addEcu,
  editEcu,
  batchDeleteCarEcu: batchDeleteCarEcu,
  importEcuList: importEcuList,
  importEcuTemplate: importEcuTemplate,
  exportEcuList: exportEcuList,
  syncEcuGcy: syncEcuGcy,
  getSupplier,
  getSoftDID,
  getEcuListByModelCode
}
